<template>
  <el-card shadow="never">
    <ele-pro-table
        ref="table"
        :where="where"
        :datasource="url"
        :columns="columns"
        need-page
        height="calc(100vh - 260px)">
      <template slot="level" slot-scope="{row}">
        <el-tag v-if="row.level === 1" type="success" size="small">一级</el-tag>
        <el-tag v-if="row.level === 2" type="success" size="small">二级</el-tag>
      </template>
      <template slot="value" slot-scope="{row}">
        {{ row.last_cycle }} => {{ row.now_cycle }}
      </template>
    </ele-pro-table>
  </el-card>
</template>

<script>

export default {
  props: {
    visible: Boolean,
    data: Object
  },
  data() {
    return {
      url: '/early_warning/list',
      where: {},
      columns: [
        {
          type: 'index',
          label: '序号',
          width: 60,
          fixed: 'left',
          align: 'center',
        }, {
          prop: 'unit',
          label: '单位',
          minWidth: 120,
        }, {
          prop: 'city',
          label: '市区',
          minWidth: 120,
        }, {
          prop: 'street',
          label: '街道',
          minWidth: 120,
        }, {
          slot: 'level',
          label: '异常等级',
          width: 80,
          align: 'center',
        }, {
          prop: 'exception_category',
          label: '异常名称',
          minWidth: 80,
          align: 'center',
        }, {
          prop: 'rule_cycle',
          label: '维度',
          width: 80,
          align: 'center',
        }, {
          prop: 'chain',
          label: '异常参数值',
          width: 120,
          align: 'center',
        }, {
          prop: 'create_time',
          label: '时间',
          width: 120,
          align: 'center',
        }, {
          prop: 'feedback',
          label: '反馈',
          minWidth: 160,
          align: 'center',
        }
      ]
    }
  },
  methods: {
    updateVisible(value) {
      this.$emit('update:visible', value)
    }
  }
}
</script>

<style scoped>
</style>
